﻿@page "/student"
@inject HttpClient Http
@using BlazorApp.Model;


<Table TItem="Student" ShowEmpty="true" ShowLoading="true"
       IsPagination="true" PageItemsSource="@PageItemsSource"
       IsStriped="true" IsBordered="true" IsMultipleSelect="true"
       ShowToolbar="true" ShowExtendButtons="true" ShowSkeleton="true"
       AddModalTitle="学生新增窗口" EditModalTitle="学生编辑窗口"
       ShowSearch="true" ShowSearchText="false" OnQueryAsync="@OnQueryAsync" OnResetSearchAsync="@OnResetSearchAsync"
       OnAddAsync="@OnAddAsync" OnSaveAsync="@OnSaveAsync" OnDeleteAsync="@OnDeleteAsync">
    <TableColumns>
        <TableColumn @bind-Field="@context.Name" Searchable="true" Sortable="true" />
        <TableColumn @bind-Field="@context.State" Lookup="@StateItems" Searchable="true">
            <SearchTemplate Context="v">
                <div class="form-group col-12 col-sm-6">
                    <RadioListX Items="@StateItems" @bind-Value="(v as Student).State" />
                </div>
            </SearchTemplate>
            <EditTemplate Context="v">
                <div class="form-group col-12 col-sm-6">
                    <RadioListX Items="@StateItems" @bind-Value="(v as Student).State" isNotNull="true" />
                </div>
            </EditTemplate>
        </TableColumn>
        <TableColumn @bind-Field="@context.Sex" Lookup="@SexItems" Searchable="true">
            <SearchTemplate Context="v">
                <div class="form-group col-12 col-sm-6">
                    <RadioListX Items="@SexItems" @bind-Value="(v as Student).Sex" />
                </div>
            </SearchTemplate>
            <EditTemplate Context="v">
                <div class="form-group col-12 col-sm-6">
                    <RadioListX Items="@SexItems" @bind-Value="(v as Student).Sex" isNotNull="true" />
                </div>
            </EditTemplate>
        </TableColumn>
        <TableColumn @bind-Field="@context.Birth" Searchable="true" Sortable="true" FormatString="yyyy-MM-dd">
            <SearchTemplate Context="v">
                <div class="form-group col-12 col-sm-6">
                    <label class="form-label">生日</label>
                    <div class="row">
                        <DateTimePicker @bind-Value="@Birth_Start" ShowLabel="false" class="col-5 d-inline-block" />
                        <div class="col-1 d-inline-block">至</div>
                        <DateTimePicker @bind-Value="@Birth_End" ShowLabel="false" class="col-5 d-inline-block"/>
                    </div>
                </div>
            </SearchTemplate>
        </TableColumn>
        <TableColumn @bind-Field="@context.Department" Searchable="true" Sortable="true" />
        <TableColumn @bind-Field="@context.Address" Searchable="true" Sortable="true" /><!--Formatter="@AddressFormatter"-->
    </TableColumns>
</Table>

<Toast />
